package com.example.sellersale.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.sellersale.entity.CartInfo;
import com.example.sellersale.entity.Order;
import com.example.sellersale.mapper.CartInfoMapper;
import com.example.sellersale.server.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CartServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo> implements CartService {


    @Autowired
    private CartInfoMapper cartInfoMapper;
    @Override
    public CartInfo addCartInfo(CartInfo cartInfo) {
        System.out.println("==============");
        System.out.println(cartInfo);
        System.out.println("==============");
        int insert = cartInfoMapper.insert(cartInfo);

        return insert==1?cartInfo:null;
    }

    @Override
    public boolean delCartInfo(String cartId) {
        int i = cartInfoMapper.deleteById(cartId);
        return i==1;
    }

    @Override
    public CartInfo editCartInfo(CartInfo cartInfo) {
        int i = cartInfoMapper.updateById(cartInfo);
        return i==1?cartInfo:null;
    }

    @Override
    public List<CartInfo> userCart(String uId) {
        return cartInfoMapper.userCart(uId);
    }
}
